<script setup>
defineProps({
  cover: String,
  title: String,
  summary: String,
  collectNum: Number,
  viewNum: Number,
  replyNum: Number,
  lowestPrice: Number
})
</script>

<template>
  <div class="feature__item">
    <img class="img" :src="cover" alt="" />
    <div class="title">
      <div class="title__text">
        <div class="title__text__title">{{ title }}</div>
        <div class="title__text__desc">{{ summary }}</div>
      </div>
      <div class="price">￥{{ lowestPrice }}起</div>
    </div>
    <div class="info">
      <span class="info__item"> <img src="@/assets/icons/home/like.png" alt="" />{{ collectNum }}</span>
      <span class="info__item"> <img src="@/assets/icons/home/eye.png" alt="" />{{ viewNum }}</span>
      <span class="info__item" style="margin-left: 160px">
        <img src="@/assets/icons/home/comment.png" alt="" />{{ replyNum }}
      </span>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.feature__item {
  width: 404px;
  height: 360px;
  position: relative;
  transition: all 0.5s ease;
  cursor: pointer;
  .img {
    width: 404px;
    height: 288px;
    object-fit: cover;
    display: block;
  }
  // 渐变效果
  &::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 72px;
    width: 100%;
    height: 200px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    z-index: 1;
  }
  .title {
    position: absolute;
    z-index: 2;
    top: 215px;
    left: 0;
    width: 404px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    .title__text {
      width: 270px;
      padding-left: 10px;
      .title__text__title {
        font-size: 22px;
        color: #fff;
        white-space: nowrap; /* 防止文本换行 */
        overflow: hidden; /* 隐藏溢出的内容 */
        text-overflow: ellipsis; /* 使用省略号替换溢出的文本 */
      }
      .title__text__desc {
        font-size: 18px;
        color: #a1a1a1;
        white-space: nowrap; /* 防止文本换行 */
        overflow: hidden; /* 隐藏溢出的内容 */
        text-overflow: ellipsis; /* 使用省略号替换溢出的文本 */
      }
    }
    .price {
      padding: 2px 4px;
      margin-right: 10px;
      margin-top: 10px;
      background-color: #fff;
      color: #cf4444;
      font-size: 16px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .info {
    width: 100%;
    height: 72px;
    background-color: #fff;
    display: flex;
    align-items: center;
    .info__item {
      display: flex;
      align-items: center;
      margin-left: 20px;
    }
    img {
      width: 20px;
      margin-right: 2px;
    }
  }
  // 浮起动画
  &:hover {
    transform: translate3d(0, -5px, 0);
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
  }
}
</style>
